package com.aptemo.webetek.client.widgets.games;

import com.aptemo.webetek.client.widgets.NumberWidget;
import com.aptemo.webetek.shared.PickBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class PickRow
		extends FocusPanel
{

	private static PickRowUiBinder	uiBinder	= GWT.create(PickRowUiBinder.class);

	interface PickRowUiBinder extends UiBinder<Widget, PickRow>
	{
	}

	interface MyStyle extends CssResource
	{
		String winner();

		String looser();

		String mine();
	}

	@UiField
	MyStyle				style;

	@UiField
	HTMLPanel			panel;

	@UiField
	Label				pickTitle;

	@UiField
	NumberWidget		pickOdds;

	private PickBean	pick;

	public PickRow(PickBean pick)
	{
		add(uiBinder.createAndBindUi(this));

		this.pick = pick;

		pickTitle.setText(pick.getTitle());
		pickOdds.setValue(pick.getOdds());

		this.setTitle("Odds: " + pick.getOdds());

		switch (pick.getStatus())
		{
			case WON:
				panel.addStyleName(style.winner());
				panel.removeStyleName(style.looser());
				break;
			case LOOSE:
				panel.addStyleName(style.looser());
				panel.removeStyleName(style.winner());
				break;
			default:
		}
	}

	public PickBean getPick()
	{
		return pick;
	}

	public void setMine()
	{
		panel.removeStyleName(style.looser());
		panel.removeStyleName(style.winner());
		panel.addStyleName(style.mine());
	}

}
